package top.wshape1.rpc.filter;

import top.wshape1.rpc.common.exception.RpcException;
import top.wshape1.rpc.message.RpcMessage;
import top.wshape1.rpc.message.RpcResponse;

/**
 * @author Wshape1
 * @version 1.0
 * @description transform response message
 * @since 2024-02-15
 */

public abstract class AbstractResponseFilter implements Filter {

    @Override
    public boolean doFilter(RpcMessage message, FilterChain filterChain) throws RpcException {
        if (!(message instanceof RpcResponse)) {
            throw new RpcException("ResponseFilter only support RpcResponse");
        }
        return doFilter((RpcResponse) message, filterChain);
    }

    public abstract boolean doFilter(RpcResponse response, FilterChain filterChain) throws RpcException;

}
